﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace CarsTitans
{
    public class Car : Entity
    {
        public float YRot = .0f;
        public Car(string asset, ContentManager content ) : base(asset,content)
        {
        }
        public override void Update(GameTime time)
        {
            base.Update(time);
            float dt = (float)time.ElapsedGameTime.TotalSeconds;
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                YRot += dt * 2.0f;
            }
            else if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                YRot -= dt * 2.0f;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                Matrix m = Transform;
                m.Translation += Transform.Forward * 1000.0f * dt;
                Transform = m;
            }
            Matrix rot = Matrix.CreateFromYawPitchRoll(YRot, .0f, .0f);
            Transform = rot * Matrix.CreateTranslation(Transform.Translation);
        }
    }
}
